{{extend layout}}

{{block sub_menu}}
{{sub_menu(menu_items, 'weekreport')}}
{{end}}

{{block content_main}}
<style type="text/css">
<!--
div.print {float:left; margin-top:5px;}
div.condition {float:right;}
div.period {float:right;margin-top:-25px;margin-right:5px;white-space:nowrap;vertical-align:middle;}
fieldset {padding:10px;margin:10px;color:#333;border-top:#06c solid 1px;} 
fieldset.normal {padding:10px;margin:10px;color:#333;border:#06c solid 1px;} 
legend {color:#06c;font-weight:800;background:#fff;} 
.weekreport ul, .noul {list-style-type: none;margin:8px 0 4px 0;float:left;} 
.weekreport div.noul {width:100%;}
.weekreport ul li {margin-top:4px;}
#edit_desc {margin-top:10px;}
input[name=date] {width:80px;}
.not_fill {background-color:red;color:white;}

table.week-plan span.tree_indent {display: inline-block;width: 16px;height: 18px;vertical-align:middle;}
table.week-plan {border:1px solid #D9E7FF;width:100%;}
table.week-plan th {border-bottom:1px solid #D9E7FF;border-top:1px solid #D9E7FF;margin-top:15px;padding: 2px;}
table.week-plan tr {height: 30px; valign: middle;border-left:1px solid #D9E7FF;border-right:1px solid #D9E7FF;}
table.week-plan td {padding: 2px;}
table.week-plan tr:hover{background-color: #f0f0f0;}
table.week-plan a {text-decoration:none}
table.week-plan a:hover {text-decoration:underline;}
table.week-plan tr.task {background-color:#D9E7FF;}
table.week-plan tr.title {border:1px solid #D9E7FF;}
table.week-plan tr.plan {border-top:1px solid #0000FF;background-color:#FFD;}
table.week-plan tr.execute {border-bottom:1px solid #D9E7FF;;}
table.week-plan span.milestone {-webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius:10px;background-color:#11ce0e;color:#fff;padding:2px 5px;font-size:9pt;white-space:nowrap;}
table.week-plan span.plan {-webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius:10px;background-color:#969ee8;color:#fff;padding:2px 5px;font-size:9pt;white-space:nowrap;}
table.week-plan td div.delay {background-color:red;color:white;}

table.q-table {border:0;width:100%;}
table.q-table th {border-bottom:1px solid #D9E7FF;border-top:1px solid #D9E7FF;margin-top:15px;padding: 2px 8px;}
table.q-table tr {height: 30px;}
table.q-table td {padding: 2px 8px;}
table.q-table tr:hover{background-color: #f0f0f0;}

#assignments_info {}
#assignments_info div.more_link {position:relative; width:100%; height:20px;}
#assignments_info div.more_link a{position:absolute; right:10px;}
-->
</style>

<style type="text/css" media="print">
<!--
.noprint {display:none;}
div.top_header {display:none;}
nav {display:none;}
div.sidebar {display:none;}
div.weekreport-header {display:none;}
-->
</style>


<div class="content">
    <div class="box weekreport">
        {{if not print_flag:}}
        <div class="weekreport-header" style="position:relative;height:28px;">
            <div class="print">
                <a href="/weekreport/print/{{=object.id}}" target="_blank"><img src="/static/images/print.png" alt="Print" title="打印当前页" id="print" align="baseline"/></a>
            </div>
            <div class="condition">
                <input type="text" id="requirement_title" name="requirement_title" value=""></input>
                <input type="button" value="周报搜索" id="week_title_search_btn"></input>
                <a href="javascript:void(0)" id="week_search_prev_week" title="上周周报">查看上周</a>
                <a href="javascript:void(0)" id="week_search_next_week" title="下周周报">查看下周</a>
                <input type="text" id="date_search_input" name="date" value="" class="field_date"></input>
                <input type="button" value="按日期选择" id="week_search_btn"></input>
            </div>
            <div class="clear"></div>
        </div>
        {{else:}}
            <div class="noprint">
                <a href="javascript:window.print()"><img src="/static/images/print.png" alt="Print" title="打印当前页" id="print" align="baseline"/></a>
            </div>
        {{pass}}
        <h2>{{=object.requirement.title}}事项周报</h2>
        <div class="period">
            周报日期: <span>{{=object.begin_date}}</span> 至 <span>{{=object.end_date}}</span>
        </div>
        <div class="box-body">
            <fieldset>
              <legend>基本信息：</legend>
                <table class="table" width="100%">
                    <tr>
                        <td colspan="2"><b>事项名称：</b><a href="/requirements/{{=object._requirement_}}">{{=object.title}}</a></td>
                        <td><b>事项编号：</b>{{=object.req_id}}</td>
                        <td><b>事项级别：</b>{{=object.get_display_value('care_level')}}</td>
                    </tr>
                    <tr>
                        <td><b>实施方式：</b>{{=object.get_display_value('mode')}}</td>
                        <td><b>技术部主管条线：</b>{{=object.get_display_value('tx')}}</td>
                        <td><b>条线事项负责人：</b>{{=object.tx_manager}}</td>
                        <td><b>提出部门：</b>{{=object.submitter}}</td>
                    </tr>
                    <tr>
                        <td><b>联系人：</b>{{=object.contactor}}</td>
                        <td><b>主要任务承担者：</b>{{=object.get_display_value('kfzx')}}</td>
                        <td><b>事项实施负责人：</b>{{=object.exe_manager}}</td>
                        <td><b>协同配合方：</b>{{=cokfzx(object)}}</td>
                    </tr>
                </table>
            </fieldset>
            <fieldset>
              <legend>项目进展描述：</legend>
                {{from uliweb.utils.textconvert import text2html}}
                <div id="proj_desc">{{<< text2html(object.description) or '无内容'}}</div>
                    <div id="edit_desc" class="noprint"><a class="btn btn-green" href="javascript:void(0)" id="btn_edit_desc">填写项目进展</a></div>
            </fieldset>
            <fieldset>
              <legend>项目监测：</legend>
                <fieldset class="normal">
                  <legend>计划执行监测：</legend>
                    <table class="table" width="100%">
                        <tr>
                            <td><b>预计执行：</b>{{="%.1f%%" % (object.pre_execute*100)}}</td>
                            <td><b>实际进展：</b>{{=object.get_display_value('current_status')}}</td>
                            <td><b>最近投产日期：</b>{{=object.get_display_value('lastest_version_date')}}</td>
                            {{from datetime import timedelta}}
                            <td><b>拟协同投产版本数：</b>{{if object.versions>0:}}<a href="/tasks/develop/list?requirement={{=object._requirement_}}&begin_date={{=object.lastest_version_date}}&end_date={{=object.lastest_version_date+timedelta(days=3)}}">{{=object.versions}}</a>{{else:}}{{=object.versions}}{{pass}}</td>
                        </tr>
                    </table>
                </fieldset>
                <fieldset class="normal">
                  <legend>需求执行监测：</legend>
                    {{ if object.req_change_content: }}
                    <table class="table" width="100%">
                        <tr>
                            <td><b>变更内容：</b>{{=object.get_display_value('req_change_date')}} {{<< text2html(object.req_change_content)}}</td>
                        </tr>
                        <tr>
                            <td><b>变更依据：</b>{{=object.req_change_according}}</td>
                        </tr>
                    </table>
                    {{ else: }}
                        无变化
                    {{pass}}
                </fieldset>
                <fieldset class="normal">
                  <legend>方案执行监测：</legend>
                    {{ if object.design_change_content: }}
                    <table class="table" width="100%">
                        <tr>
                            <td><b>变更内容：</b>{{=object.get_display_value('design_change_date')}} {{<< text2html(object.design_change_content)}}</td>
                        </tr>
                        <tr>
                            <td><b>变更依据：</b>{{=object.design_change_according}}</td>
                        </tr>
                    </table>
                    {{ else: }}
                        无变化
                    {{pass}}
                </fieldset>
                <fieldset class="normal">
                  <legend>资源投入监测：</legend>
                    <table class="table" width="100%">
                        <tr>
                            <td><b>计划投入中心资源：</b>{{="%.1f" % object.plan_resource_center}}</td>
                            <td><b>已投入比例：</b>{{if object.input_center_per>1:}}<font color="red">{{pass}}{{="%.1f%%" % (object.input_center_per*100)}}{{if object.input_center_per>1:}}</font>{{pass}}</td>
                            <td><b>计划投入公司资源：</b>{{="%.1f" % object.plan_resource_company}}</td>
                            <td><b>已投入比例：</b>{{if object.input_company_per>1:}}<font color="red">{{pass}}{{="%.1f%%" % (object.input_company_per*100)}}{{if object.input_company_per>1:}}</font>{{pass}}</td>
                        </tr>
                    </table>
                </fieldset>
                <fieldset class="normal" id="assignments_info">
                  <legend>任务书信息：</legend>
                    {{<< view_obj.r.assignments.display}}
                </fieldset>
            </fieldset>
            <fieldset>
              <legend>问题跟踪列表：</legend>
                {{if questions_list['table']:}}
                    {{<< questions_list['table']}}
                {{else:}}
                    <div id="questions">无内容</div>
                {{pass}}
            </fieldset>
            <fieldset>
              <legend>风险跟踪列表：</legend>
                {{if risks_list['table']:}}
                    {{<< risks_list['table']}}
                {{else:}}
                    <div id="risks">无内容</div>
                {{pass}}
            </fieldset>
            <fieldset>
              <legend>本周计划执行：</legend>
                {{if cur_plans['total'] > 0:}}
                    {{<< cur_plans['table']}}
                {{else:}}
                    <div id="cur_plans">无内容</div>
                {{pass}}
            </fieldset>
            <fieldset>
              <legend>下周工作计划：</legend>
                {{if next_plans['total'] > 0:}}
                    {{<< next_plans['table']}}
                {{else:}}
                    <div id="next_plans">无内容</div>
                {{pass}}
            </fieldset>
        </div>
    </div>
</div>

{{block js}}
{{use "jquery", ui=True}}
{{use "facebox"}}
{{use "jqutils", ajaxForm=True}}
{{link "ticket/ticket.css"}}
{{use "jqeasyui"}}

<script type="text/javascript">
var post_add_desc = function(r){
    if (r.success){
        show_message(r.message);
        jQuery(document).trigger('close.facebox');
        $('#proj_desc').html(r.data).effect('highlight', 5000);
    } else if (!r.success){
        $('div.error-div').remove();
        show_message(r.message, 'error');
        $.each(r.data, function(key, value){
            var f, t, e, d;
            f = 'field_' + key;
            t = $('label[for='+f+']');
            e = $('<div class="ui-state-error error-div" style="border:0;"><span class="ui-icon ui-icon-info" style="float:left;"></span><span class="ui-state-error-text">' + value + '</span></div>');
            d = t.position();
            t.after(e);
        });
    }
}

var add_desc_click = function(){
    var a = $(this);
    var url = "/weekreport/write/{{=object.id}}"
    $.facebox(function() {
        $.get(url, function(data) {
            $.facebox(data);
            $('#edit_desc_form').ajaxForm(post_add_desc);
        });
    });
}

$(function(){
    $.facebox.settings.loadingImage = '{{=url_for_static('facebox/loading.gif')}}'
    $.facebox.settings.closeImage = '{{=url_for_static('facebox/closelabel.png')}}'
    $('#btn_edit_desc').click(add_desc_click);

    var search_week = function(data){
        $.ajax({
            type: "POST",
            url: "/weekreport/search/{{=object.id}}",
            data: data,
            success: function(r){
                if(r.success){
                    window.location.href='/weekreport/view?id='+r.data;
                }else{
                    show_message(r.message, 'error');
                }
            }
        });
    }
    $('#week_search_btn').click(function(){
        search_week({'date':$('#date_search_input').val()});
    });
    $('#week_search_prev_week').click(function(){
        search_week({'week':'prev', 'date':'{{=object.begin_date}}'});
    });
    $('#week_search_next_week').click(function(){
        search_week({'week':'next', 'date':'{{=object.begin_date}}'});
    });
    $('#week_title_search_btn').click(function(){
        window.location.href = '/weekreport/list?requirement_title=' + $('#requirement_title').val();
    });
    
    $('#assignments_info div.more').hide();
    $('#assignments_info div.more_link a').click(function(){
        $('#assignments_info div.more').toggle('fast');
    });
});
</script>

{{end}}

{{end}}
